#include <pybind11/pybind11.h>

extern "C" {
#include "../virtio_disk.h"
}

namespace py = pybind11;

PYBIND11_MODULE(lfs, m) {
    py::class_<buf>(m, "Buf")
        .def(py::init<>())
        .def_readwrite("valid", &buf::valid)
        .def_readwrite("disk", &buf::disk)
        .def_readwrite("blockno", &buf::blockno)
        .def_readwrite("dev", &buf::dev)
        .def_property_readonly("data",
            [](buf &b) -> py::list {
                py::list result;
                for (size_t i=0; i < BSIZE; ++i) {
                    result.append(b.data[i]);
                }
                return result;
            })
        .def("setData", 
            [](buf &b, uchar c) -> void {
                buf_set_char(&b, c);
            });

    m.def("virtio_init", &virtio_init)
        .def("virtio_disk_read", virtio_disk_read)
        .def("virtio_disk_write", virtio_disk_write);
}

